import java.io.*;
import java.net.*;

public class JavaClientTCP{
  
  public static void main(String[] args) throws IOException {
    
    final String SERVER = "aludra.usc.edu";
    final int PORT = 2000;
    InetAddress remoteHost = InetAddress.getByName(SERVER);

    //Get User Input
    System.out.println("Enter Text :");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String userText = null;
    
    try{
	    userText = br.readLine();
	
    }catch(IOException e){
	     e.printStackTrace();
    }

    byte[] message = userText.getBytes();

    //Send to the TCP Server
    Socket clientSocket = new Socket(remoteHost,PORT);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(clientSocket.getOutputStream()));
    pw.write(userText);
    pw.flush();
    clientSocket.close();     

    
    System.out.println("Text sent to Server at : "+ SERVER + " on port # " + PORT );
	System.out.println("\n");
	
  }

}